package com.maozzi.common.exception;

import com.maozzi.common.enums.BizCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 业务异常
 *
 * @author maozi
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class BizException extends RuntimeException {
    /**
     * 错误码
     */
    private String code;

    public BizException(BizCodeEnum codeEnum) {
        super(codeEnum.getDescription());
        this.code = codeEnum.getCode();
    }

    public BizException(BizCodeEnum codeEnum, String message) {
        super(message);
        this.code = codeEnum.getCode();
    }

    public BizException(BizCodeEnum codeEnum, Throwable cause) {
        super(codeEnum.getDescription(), cause);
        this.code = codeEnum.getCode();
    }

    public BizException(String code, String message) {
        super(message);
        this.code = code;
    }

    public BizException(String code, String message, Throwable cause) {
        super(message, cause);
        this.code = code;
    }

}
